package course11;

import java.util.HashMap;
import java.util.Map;

public class Hash3 {

    public static void main(String[] args) {

        Map<String, Hero> sanGuo = new HashMap<>();
        Map<String, Hero> changCheng = new HashMap<>();
        Map<String, Hero> yaoGuai = new HashMap<>();

        Hero liuBei = new Hero();
        Hero guanYu = new Hero();
        Hero zhangFei = new Hero();

        Hero huaMuLan = new Hero();
        Hero suLie = new Hero();
        Hero baiLiShouYue = new Hero();

        Hero daJi = new Hero();
        Hero mengQi = new Hero();
        Hero peiQinHu = new Hero();

        liuBei.setSex("男");
        liuBei.setName("刘备");
        sanGuo.put(liuBei.getName(), liuBei);

        guanYu.setSex("男");
        guanYu.setName("关羽");
        sanGuo.put(guanYu.getName(), guanYu);

        zhangFei.setSex("男");
        zhangFei.setName("张飞");
        sanGuo.put(zhangFei.getName(), zhangFei);


        huaMuLan.setSex("女");
        huaMuLan.setName("花木兰");
        changCheng.put(huaMuLan.getName(), huaMuLan);

        suLie.setSex("男");
        suLie.setName("苏烈");
        changCheng.put(suLie.getName(), suLie);

        baiLiShouYue.setSex("男");
        baiLiShouYue.setName("百里守约");
        changCheng.put(baiLiShouYue.getName(), baiLiShouYue);


        daJi.setSex("女");
        daJi.setName("妲己");
        yaoGuai.put(daJi.getName(), daJi);

        mengQi.setSex("男");
        mengQi.setName("梦奇");
        yaoGuai.put(mengQi.getName(), mengQi);

        peiQinHu.setSex("男");
        peiQinHu.setName("裴擒虎");
        yaoGuai.put(peiQinHu.getName(), peiQinHu);

        Map<String, Map<String, Hero>> wangZheRongYao = new HashMap<>();
        wangZheRongYao.put("三国", sanGuo);
        wangZheRongYao.put("长城小分队", changCheng);
        wangZheRongYao.put("妖怪",yaoGuai);

        System.out.println(wangZheRongYao.get("妖怪").get("妲己").getName());

        // 嵌套的遍历
        wangZheRongYao.forEach((key, value) ->{
            System.out.println("key: " + key + "\tvalue: " + value);
        });  //结果如何优化？

    }
}
